#!/bin/bash

count=()
name=("岑兴" "罗曦" "江晖" "骆天培" "罗蒙" "文星月" "罗喆" "王梦媛" "赵晓枫" "王浩垚" "何宏杨" "王钰莹")

dianming() {
local idx
local randomname

if [ ${#name[@]} -gt 0 ]; then

	idx=$((RANDOM % ${#name[@]}))
    randomname=${name[$idx]}

	if [[ ! "${count[@]}" == "*($randomname)*" ]];then
		echo "恭喜你被点到了，去吧皮卡丘$randomname"
		unset name[$idx]
		name=("${name[@]:0:$idx}" "${name[@]:$((idx+1))}")
		count+=("$idx")
	else
		dianming
	fi
else
	echo "所有的学生都被点完咯"
	exit 0
fi

}

while true; do
	read -p "回车点名下一个"
	dianming
done
